home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7247 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: pegasus.montclair.edu!harmon
  2. From: harmon@pegasus.montclair.edu (Derek Harmon)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Data Conversions
  5. Date: 8 Feb 1996 20:28:13 -0500
  6. Organization: Montclair State University
  7. Message-ID: <harmon.823829188@pegasus.montclair.edu>
  8. References: <4fbfqp$fsk@madeline.INS.CWRU.Edu>
  9. NNTP-Posting-Host: pegasus.montclair.edu
  10. X-Newsreader: NN version 6.5.0 #68 (NOV)
  11.  
  12. ** Quoting a message by <mab22@po.CWRU.Edu> dated <8-Feb-1996>:
  13.  
  14. > Are there any pre-existing routines to do data conversions?
  15. ... [convert type A to type B, type A in Visual BASIC to type Z used only
  16. by Martian computers, etc] ... :)
  17.  
  18. > void Translate(long dataType,long length,char *inData,
  19.                  long outDataType, long outLength,char *outData);
  20.  
  21. > Unfortunately, it's either suffered speed drawbacks or become very
  22. > complicated in terms of adding data types.  (One function is needed for
  23. > every type of datatype conversion)
  24.  
  25.   That's understandable, as Translate() would be too-general to be implemented
  26. for all data types, and a switch statement would be slow to dispatch amongst
  27. many specific subfunctions.  I'd suggest calling the single functions with a
  28. uniform API, collecting them all into one .H to be kept by your terminal in
  29. hardcopy, and making a library of them:
  30.  
  31. void XXXtoYYY([best fit type of XXX] *dest, const [best fit type of YYY] *src);
  32.  
  33.   Each XXXtoYYY() would know the lengths of the datum it would convert.  It
  34. is already a commonality in many C functions (strcpy, strcat, etc) to have
  35. dest before src in the parameter listing, e.g. the shorthand, dest <- src.
  36.  
  37. > Surely, somebody has run into this problem before and solved it?
  38.  
  39.   People run into this problem everyday, then they take their coffee
  40. breaks.  :)
  41.  
  42. > written C programs to deal with them and created a nice set of
  43. > public-domain translation routines, right?
  44.   ^^^^^^^^^^^^^
  45.   There's too much $$$ to be made for such libraries.  Data formats are
  46. afflicted by the curse of the Tower of Babble.  There are no standards,
  47. there are only standardization efforts (cf. FITS).
  48.  
  49.                                                          -- Stone
  50. --
  51. [ SSS TTT OOO N  N EEE ] Derek Harmon (a.k.a. Stonelight)
  52. [ S_   T  O O NN N E_  ] E-Mail: harmon@pegasus.montclair.edu
  53. [   S  T  O O N NN E   ] Computer Science Undergrad at
  54. [ SSS  T  OOO N  N EEE ] Montclair State University, NJ
  55. (My views are entirely my own, nobody else is this creative :)
  56.  
  57.  
  58.